<?php
namespace Admin\Controller;
use Admin\Controller\CommonController;
class IndexController extends CommonController {

  
    public function index() {
 
		    $menu=M('two_level')->select();
        $menu1=M('three_level')->select();
       //  $rule=M('auth_rule')->where('pid=0')->limit(2,22)->select();
       //  foreach ($rule as &$value) {
       //             $erji=M('auth_rule')->where('pid='.$value['id'])->select();
       //             $value['erji']=$erji;
       //  }
        
    
       // $this->assign("rule",$rule);
        $this->assign("menu",$menu);
        $this->assign("menu1",$menu1);
        $this->display();
    }
	
   public function welcome(){
   	 // pre($_SESSION['my_info']);
   	// 服务器信息
   	if (function_exists('gd_info')) {
   		$gd = gd_info();
   		$gd = $gd['GD Version'];
   	} else {
   		$gd = "不支持";
   	}
   	$info = array(
   			'操作系统' => PHP_OS,
   			'主机名IP端口' => $_SERVER['SERVER_NAME'] . ' (' . $_SERVER['SERVER_ADDR'] . ':' . $_SERVER['SERVER_PORT'] . ')',
   			'运行环境' => $_SERVER["SERVER_SOFTWARE"],
   			'PHP运行方式' => php_sapi_name(),
   			'程序目录' => SITE_ROOT,
   			'MYSQL版本' => function_exists("mysql_close") ? mysql_get_client_info() : '不支持',
   			'GD库版本' => $gd,
   			// 'MYSQL版本' => mysql_get_server_info(),
   			'上传附件限制' => ini_get('upload_max_filesize'),
   			'执行时间限制' => ini_get('max_execution_time') . "秒",
   			'剩余空间' => round((@disk_free_space(".") / (1024 * 1024)), 2) . 'M',
   			'服务器时间' => date("Y年n月j日 H:i:s"),
   			'北京时间' => gmdate("Y年n月j日 H:i:s", time() + 8 * 3600),
   			'采集函数检测' => ini_get('allow_url_fopen') ? '支持' : '不支持',
   			'register_globals' => get_cfg_var("register_globals") == "1" ? "ON" : "OFF",
   			'magic_quotes_gpc' => (1 === get_magic_quotes_gpc()) ? 'YES' : 'NO',
   			'magic_quotes_runtime' => (1 === get_magic_quotes_runtime()) ? 'YES' : 'NO',
   	);
            
          $userc=M('user')->count();
          $wherearr['create_time']=array('EGT',strtotime(date('Y-m-d')));
          $usertoday=M('user')->where($wherearr)->count();
      
          $dingdanc=M('dingdan')->count();
          $wheredd['time']=array('EGT',strtotime(date('Y-m-d')));
          $dingdantoday=M('dingdan')->where($wheredd)->count();
          $shangpinc=M('shangpin')->count();
          $wheresp['addtime']=array('EGT',strtotime(date('Y-m-d')));
          $shangpintoday=M('shangpin')->where($wheresp)->count();
          $this->assign("userc", $userc);
          $this->assign("usertoday", $usertoday);
          $this->assign("dingdanc", $dingdanc);
          $this->assign("dingdantoday", $dingdantoday);
          $this->assign("shangpinc", $shangpinc);
           $this->assign("shangpintoday", $shangpintoday);
   	$this->assign('server_info', $info);
   	$this->display();
   }
	public function myInfo() {
        if (IS_POST) {
            $this->checkToken();
            echo json_encode(D("Index")->my_info($_POST));
        } else {
            $this->display();
        }
    }

    public function cache() {
        $caches = array(
            "HomeCache"    => array("name" => "网站前台缓存文件", "path" => CACHE_PATH . "Home/"),
            "AdminCache"   => array("name" => "网站后台缓存文件", "path" => CACHE_PATH . "Admin/"),
            //"HomeData"     => array("name" => "网站前台数据库字段缓存文件", "path" => DATA_PATH),
            "AdminData"    => array("name" => "网站数据库字段缓存文件", "path" => DATA_PATH),
            //"HomeLog"      => array("name" => "网站前台日志缓存文件", "path" => LOG_PATH),
            "AdminLog"     => array("name" => "网站日志缓存文件", "path" => LOG_PATH),
            //"HomeTemp"     => array("name" => "网站前台临时缓存文件", "path" => TEMP_PATH),
            "AdminTemp"    => array("name" => "网站临时缓存文件", "path" => TEMP_PATH),
            //"Homeruntime"  => array("name" => "网站前台runtime.php缓存文件", "path" => CACHE_PATH . "Home/~runtime.php"),
            //"Adminruntime" => array("name" => "网站后台runtime.php缓存文件", "path" => CACHE_PATH . "Admin/~runtime.php")
        );
        if (IS_POST) {
            foreach ($_POST['cache'] as $path) {
                if (isset($caches[$path]))
                    delDirAndFile($caches[$path]['path']);
            }
			// pre($_POST);
			// $this->checkToken();
            echo json_encode(array("status"=>1,"info"=>"缓存文件已清除"));
        } else {
            $this->assign("caches", $caches);
            $this->display();
        }
    }

}

?>